//
//  main.m
//  Homework_03 - NSString NSArray NSMutableArray
//
//  Created by 岁变 on 16/7/6.
//  Copyright © 2016年 岁变. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Book.h"
#import "BookManager.h"

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        
//       1. 截取字符串 "20|https://www.baidu.com" 中 "|" 前面和后⾯的字符串, 并输出
//       2. 向可变数组里存储 int、float、double、BOOL类型等数据(不能使用字面量)
//       3. 实现图书管理系统(BookManager类)：
//        使用数组管理所有书籍(Book类)。
//        BookManager类属性数组可以添加、删除。
//        可以从数组根据书名查找书籍，并修改书籍的价格。
//        展示所有书籍清单（书名）
        
        //1.
        NSString *str1 = @"20|https://www.baidu.com";
        NSArray *arr = [str1 componentsSeparatedByString:@"|"];
        for (NSString *str in arr) {
            NSLog(@"%@", str);
        }
        
        //2
        NSNumber *aNumber = [NSNumber numberWithInt:20];
        NSNumber *bNumber = [NSNumber numberWithFloat:1.2];
        NSNumber *cNumber = [NSNumber numberWithDouble:2134.1234198749184571];
        NSNumber *dNumber = [NSNumber numberWithBool:YES];
        
        NSMutableArray *mArr = [NSMutableArray array];
        [mArr addObject:aNumber];
        [mArr addObject:bNumber];
        [mArr addObject:cNumber];
        [mArr addObject:dNumber];
        NSLog(@"%@", mArr);
        
        //3
        BookManager *BMan = [[BookManager alloc] init];
        Book *book1 = [Book bookWithName:@"水浒传" price:@"26"];
        Book *book2 = [Book bookWithName:@"西游记" price:@"29"];
        Book *book3 = [Book bookWithName:@"三国演义" price:@"54"];
        [BMan addBook:book1];
        [BMan addBook:book1];
        [BMan addBook:book2];
        [BMan addBook:book3];
        [BMan deleteBook:@"水浒传"];
        [BMan modifiedPrice:@"三国演义" price:@"28"];
        [BMan showAllBook];

        
        
    }
    return 0;
}
